﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Admin/Views/Shared/AdminSite.Master" Inherits="System.Web.Mvc.ViewPage<List<MensUnoShop.Models.OrderData>>" %>
<%@ Import Namespace="MvcPaging"%>  
<%@ Import Namespace="MensUnoShop.Helpers" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	出貨單
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<script type="text/javascript" language="javascript">
    function changeordership(oguid) {
        var answer = confirm("是否要將所選取的訂單匯出為出貨單?");
        if (answer) {
            var jsonstring = { "oguid": oguid, "changeordership": "1" };
            $.ajax({
                type: "POST",
                traditional: true,
                url: "/Admin/OrderManagement/OrderShip",
                data: jsonstring,
                dataType: "json",
                success: function (data) {
                    if (data.code == "200") {
                        alert("狀態變更成功!");
                        location.href = 'OrderListPaid?page=0';
                        //$("#tr_" + oguid).remove();
                    }
                    else
                        alert(data.response);
                }
            });
        }        
    }
    function changeordership2() {
       var answer = confirm("是否要將所選取的訂單匯出為出貨單?");
       if (answer) {
           var oguid = $('input:checkbox:checked[name="cbcb"]').map(function () { return $(this).val(); }).get();
           var oguidstr = oguid.toString();
           oguidstr = oguidstr.replace(/\,/g, '.');
           var jsonstring = { "oguid": oguidstr, "changeordership": "2" };
           $.ajax({
               type: "POST",
               traditional: true,
               url: "/Admin/OrderManagement/OrderShip",
               data: jsonstring,
               dataType: "json",
               success: function (data) {
                   if (data.code == "200") {
                       alert("狀態變更成功!");
                       location.href = 'OrderListPaid?page=0';
                       //$("#tr_" + oguid).remove();
                   }
                   else
                       alert(data.response);
               }
           });       
       }
    }    
</script>


<div id="main-content" class="hastable" style="margin:0 auto;">
		    <div class="title title-spacing">
			    <h2>出貨單</h2>
					付款完成等待出貨的訂單
		    </div>
            <input type="button" name="selectall" id="selectall" value="全選" class="submit" onclick="if(confirm('是否要將所選取的訂單匯出為出貨單?')){$('input:checkbox').each(function(){$(this).attr('checked','checked');});}" />
            <input type="button" name="changeordership2" id="changeordership2" value="執行匯出" class="submit" onclick="javascript:changeordership2();" />            
            <table cellspacing="0" style="width:2500px">
            <thead>
        	<tr>
                <td style="width:20px"></td>                
                <td style="width:100px">訂單編號</td>
                <td style="width:80px">金流編號</td>
                <%--<th style="width:100px">訂單金額</th>--%>
                <td style="width:180px">會員帳號</td>
                <td>會員姓名</td>
                <td style="width:100px">產品編號</td>
                <td style="width:200px">品名</td>                
                <td style="width:40px">顏色</td>
                <td>尺寸</td>
                <td>數量</td>
                <td>商品金額</td>
                <td>運送方法</td>
                <td>運費</td>
                <td style="width:200px">客戶意見欄</td>
                <td>收件人姓名</td>
                <td>收件人電話</td>
                <td>收件人地址</td>
                <td style="width:60px">發票類型</td>
                <td style="width:100px">發票抬頭</td>
                <td style="width:80px">發票統編</td>
                <td>入帳時間</td>
                <td>付款方式</td>
                <td></td>
                <td></td>
                <td></td>
            </tr>            
        </thead>        
            <%if (Model != null){%>
             <tbody>
            <%foreach (var item in Model)
            {  %>
        	<tr id="tr1" name="tr_<%:item.OGUID %>">
                <td><input type="checkbox" id="cb_<%:item.OGUID %>" name="cbcb" value="<%:item.OGUID %>" /></td>                
                <td><%:item.OTXID %></td>
                <td><%:item.OCASHID %></td>
                <%--<th><%:item.ORDERPRICE %></th>--%>
                <td><%:item.MEMAIL %></td>
                <td style="width:80px"><%:item.MNAME %></td>
                <td><%:item.MOKSN %></td>
                <td><%:item.MOKTITLE %></td>                
                <td><%:item.COLOR %></td>
                <td><%:item.SPEC %></td>
                <td><%:item.MOKAMOUNT %></td>
                <td><%:item.MOKPRICE %></td>
                <td><%=Html.GetShippingWay(item.OSHIPPINGWAY)%></td>
                <td><%:item.ODELIVERY%></td>
                <td><%:item.RCCUSTOMER %></td>
                <td><%:item.RCNAME %></td>
                <td><%:item.RCTEL %></td>
                <td><%:item.RCCOUNTRY %><%:item.RCZIP %><%:item.RCCITY %><%:item.RCAREA %><%:item.RCADDRESS %></td>
                <td><%=Html.GetInvoiceType(item.OINVOICETYPE)%></td>
                <td><%:item.OINVOICETITLE %></td>
                <td><%:item.OINVOICESERIAL %></td>
                <td><%:item.OSTATUSDATEIN.GetValueOrDefault().ToString("yyyy/MM/dd HH:mm:ss")%></td>
                <td><%=Html.GetPayType(item.PAYTYPE)%></td>
                <td><input type="button" name="changeordership" id="changeordership" value="單筆匯出" onclick="javascript:changeordership('<%:item.OGUID %>');" /></td>
                <td><a id="OrderDetail" name="OrderDetail" class="iframe" href="OrderDetailView/<%:item.OGUID %>">訂單明細</a></td>
                <td><a id="MemberDetail" name="MemberDetail" class="iframe" href="../MemberManagement/MemberDetailView/<%:item.MGUID %>">會員資料</a></td>                
            </tr>
            <%} %>
            </tbody>
            <%} %>
            </table>

            <br/><br/>　
        </div>

<script type="text/javascript">
    $("a#OrderDetail").fancybox({ width: 810 });
    $("a#MemberDetail").fancybox({ height: 400, scrolling: 'no' });
</script>
</asp:Content>
